package com.wdf.aop.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class HttpAspect {
    //定义一个公用方法
    @Pointcut("execution(public * com.wdf.aop.controller..*.*(..))")
    public void log(){
    }

    @Before("log()")
    public void doBefore(JoinPoint joinPoint){
        System.out.println("方法调用前。。。。");
        String name = joinPoint.getSignature().getName();
        System.out.println("方法名称"+name);
        Object[] args = joinPoint.getArgs();
        System.out.println("方法参数"+args[0].toString());

    }

    @After("log()")
    public void doAfter(){
        System.out.println("方法调用后。。。。");
    }

    @AfterReturning(returning="obj", pointcut = "log()")
    public void doAfterReturnig(Object obj){
        System.out.println("返回值。。。。"+obj);
    }
//    @Around("log()")
//    public void doAround(ProceedingJoinPoint proceedingJoinPoint){
//        System.out.println("环绕。。。。");
//    }

}
